﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PosuvnikyTest.Models;

namespace PosuvnikyTest.Services
{
    public interface IDefaultSettingsService
    {
        DefaultSettings GenerateDefaultSettings();
    }

    public class DefaultSettingsService : IDefaultSettingsService
    {
        public DefaultSettings GenerateDefaultSettings()
        {
            var model = new DefaultSettings();
            model.DefaultPrice = GetAdvertPriceByTerm(0);
            return model;
        }

        public decimal GetAdvertPriceByTerm(int dayCounts)
        {
            if (dayCounts>=0 && dayCounts < 5)
            {
                return 10;
            }
            if (dayCounts < 10)
            {
                return 20;
            }
            if (dayCounts < 30)
            {
                return 50;
            }
            if (dayCounts < 30*6)
            {
                return 100;
            }
            if (dayCounts < 30*12)
            {
                return 500;
            }
            return 1000;
        }

        public double GetDiscountByTerm(int dayCounts)
        {
            if (dayCounts >= 0 && dayCounts < 5)
            {
                return 0.01;
            }
            if (dayCounts < 10)
            {
                return 0.05;
            }
            if (dayCounts < 30)
            {
                return 0.1;
            }
            if (dayCounts < 30 * 6)
            {
                return 0.2;
            }
            if (dayCounts < 30 * 12)
            {
                return 0.5;
            }
            return 0.9;
        }
    }
}